<template>
    <div class='playlist'>
        <van-nav-bar
        
        left-text="歌单"
        right-text="更多"
        left-arrow
        @click-left="onClickLeft"
        
        />
        <!-- 标签栏滚动 -->
        <van-tabs @click="change">
            <van-tab v-for="item in tags" :title="item.name" :key="item.id" @resize="initReleat(item.id)" >
           <p class="all">全部{{item.name }}</p>
           <ul class="songs">
                <li v-for="item in playlists" :key="item.id" @click="gosongListDettail(item.id)">
                    <img :src="item.coverImgUrl" alt="">
                    <p class="songsheetname">{{item.name}}</p>
                    <span class="songsheetplay"><van-icon name="play" />{{
                (item.playCount / 10000).toFixed(1) + "万"
              }}</span>
                </li>
           </ul>
            </van-tab>
        </van-tabs>
        
    </div>
</template>

<script>
import {PlaylisttagAPI} from "../../api/home"
import axios from "axios";
export default {
    
    data() {
        return {
            tags:[],
            playlists:[],
        };
    },
    computed: {},
    watch: {},
    
    methods: {
        onClickLeft(){
           this.$router.push("/home")
        },
        //精选歌单分类接口
       async initTags(){
            const res = await PlaylisttagAPI();
            console.log(res)
            this.tags =res.data.tags;
            
        },
        //精选歌单对应的页面
        async change(name = 0,title= "华语"){
            console.log(name,title);
             const res = await axios.get("http://localhost:3000/top/playlist/highquality?cat="+title);
             console.log("分类下的歌单",res);
             this.playlists = res.data.playlists;
             console.log("123",this.playlists)
             
         },
         //歌单跳转详情
        gosongListDettail(id){
             this.$router.push(`/gedandetail/${id}`)
         }
        


    },
    created() {
        this.initTags()
        this.change()
    },
    mounted() {
        
    },
    components: {},
    }
</script>
<style scoped>
    .songs{
      text-align: center;
    }
    li{
      
       display: inline-block;
        width: 30%;
        margin-top: 10px;
        padding-bottom: 10px;
        position: relative;
    }
    img{
        width: 100px;
        height: 100px;
        border-radius: 15px;

    }
    .songsheetname {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  width: 100%;
  margin-top: 3px;
}
    .songsheetplay {
  display: inline-block;
  box-sizing: border-box;
  padding: 1px 8px 2px 4px;
  background-color: rgba(0, 0, 0, 0.329);
  border-radius: 20px;
  color: #fff;
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 14px;
  
}
</style>